package client.construct.prototype.deepclone;

import org.junit.Test;
import uml.construct.prototype.deepclone.Attachment;
import uml.construct.prototype.deepclone.MonthlyLog;

import java.io.IOException;

/**
 * 深克隆--客户端<br>
 * 提供序列化和反序列化实现<br>
 * on 2022/12/30 21:27
 */
public class Client {
    @Test
    public void t() {
        MonthlyLog log = null, deeplyClonedLog = null;
        Attachment attachment, deeplyClonedAttachment = null;
        log = new MonthlyLog("12月份报", "2022/12/30", "盈亏不详");
        attachment = new Attachment("12月份月报附件.word");
        log.setAttachment(attachment);
        try {
            deeplyClonedLog = log.deeplyClone();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        System.out.println(log == deeplyClonedLog);//false
        System.out.println(attachment == deeplyClonedLog.getAttachment());//false
        attachment.download();
        deeplyClonedLog.getAttachment().download();
    }

}
